<?php
/*======================================================================
 パスワード再設定用テーブルのごみを削除する
 有効期限を過ぎたレコードを削除する
======================================================================*/

date_default_timezone_set('Asia/Tokyo');

//DB接続パラメータ
$db_host    = "localhost";
$db_port    = 5432;
$db_name    = "dummy_db";
$db_user    = "dummy_user";
$db_passwd  = "dummy_password";

//--------------------------------------------------

$param = 'host='.$db_host.' port='.$db_port.' dbname='.$db_name.' user='.$db_user.' password='.$db_passwd;
$con = pg_connect($param);
if(!$con)
{
    syslog(LOG_ERR, pg_last_error());
    exit();
}
$sql  = "DELETE ";
$sql .= "FROM ";
$sql .= "  password_reset_info ";
$sql .= "WHERE ";
$sql .= "  expire_datetime <= '".date('Y-m-d H:i:s',time())."'";
$rs = pg_query($con, $sql);
pg_close($con);

syslog(LOG_INFO, "ceanPasswordResetInfo completed.");
closelog();
